<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Zentia</title>
    <link href="/public/icon.png" rel="icon" type="image/x-icon">
	<link href="/public/admin/layui/css/layui.css" rel="stylesheet">
	<link href="/public/index/css/game.css" rel="stylesheet">
</head>

{block name="body"}

{/block}
<script src="/public/admin/layui/layui.js"></script>
<script>
layui.config({
	base: '/public/index/js/',
	version : true,
}).extend({
	layajax: 'layajax'
});

layui.use(['jquery','element','layer','form'], function(){
	var $ = layui.jquery
	,layer = layui.layer
	,element = layui.element
	,form = layui.form;
	
	//表单submit监听
	form.on('submit(*)', function(data){
		var action = $('.layui-form').attr('action');
		var ary = data.field;
		$.ajax({
			url: action,
			data: ary,
			type: "post",
			dataType:'json',
			success:function(res){
				console.log(res);
				//数据处理
				if(res.code==1){
					layer.msg(res.msg, {icon: 6,time:1000}, function(index){
						layer.close(index);
						window.location.href = res.data.url;
					});
				}
				if(res.code==0){
					layer.msg(res.msg, {icon:2,time:1000});
				}
			},error: function(res){
				console.log(res);
				layer.msg('致命错误');
			}
		});
		return false;
	});
	
	//表单search监听
	form.on('submit(search)', function(data){
		$(this).submit();
	});
	
});
</script>
<!--脚本文件开始-->
{block name="script"} {/block}
<!--脚本文件结束-->
</html>
